<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery-3.5.1.min.js"></script>
</head>
<body>
 <input type="hidden" id="url">
 <pre id="parameter"></pre>
 <pre id="result"></pre>
</body>
<script type="text/javascript">
    var win = window;
    window.onbeforeunload = function(e) {
        win.location.href = "/pages/dms/black.html";
        var url = $("#url").val()
        if(!url){ return ;}
        win.history.replaceState("", "", url);
        var parameter = $("#parameter").text();
        $.ajax({
            url: $("#url").val(),
            data: JSON.stringify(parameter),
            method: "post",
            dataType: "json",
            contentType: 'application/json',
            success: function (data) {
                alert(2);
                var preInput = win.document.getElementById('parameter');
                preInput.innerHTML = JSON.stringify(parameter,null,4);
                win.document.body.appendChild(preInput);

                var preOutput = win.document.getElementById('result');
                preOutput.innerHTML = JSON.stringify(data,null,4);
                //win.document.body.appendChild(preOutput);
            }
        });

        var dialogText = 'Dialog text here';
        e.returnValue = dialogText;
        return dialogText;
    };
</script>
</html>